{template 'common/header'}

<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('goods', array('op'=>'display'));}">商品列表</a></li>
	<li><a href="{php echo $this->createWebUrl('goods', array('op'=>'edit'));}">添加商品</a></li>
</ul>

<div class="main">
	<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="{$_GPC['c']}">
			<input type="hidden" name="a" value="{$_GPC['a']}">
			<input type="hidden" name="do" value="{$_GPC['do']}">
			<input type="hidden" name="m" value="{$_GPC['m']}">
			<input type="hidden" name="op" value="{$op}">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
					<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6">
						<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="品名或编码">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
					<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6">
						<select name="status" class="form-control">
							<option value="0" {if intval($_GPC['status']) == 0}selected="selected"{/if}>全部</option>
							<option value="1" {if intval($_GPC['status']) == 1}selected="selected"{/if}>下架</option>
							<option value="2" {if intval($_GPC['status']) == 2}selected="selected"{/if}>上架</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">分类</label>
					<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6">
						<select class="form-control" name="categoryid">
							<option value="0" {if intval($_GPC['categoryid']) == 0}selected="selected"{/if}>全部分类</option>
							{loop $categories $cid $category}
							<option value="{$cid}" {if intval($_GPC['categoryid']) == $cid}selected="selected"{/if}>{$category['name']}</option>
							{/loop}
						</select>
					</div>
					<div class="col-xs-12 col-sm-2 col-md-1 col-lg-1">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="panel panel-default">
		<div class="panel-heading">商品列表</div>
		<div class="panel-body">
			<div class="table-responsive panel-body">
				<table class="table table-hover" style="min-width: 300px;">
					<thead class="navbar-inner">
						<tr>
							<th class="col-sm-2">品名</th>
							<th class="col-sm-2">编码</th>
							<th class="col-sm-2">外观</th>
							<th class="col-sm-1">进价</th>
							<th class="col-sm-1">售价</th>
							<th class="col-sm-1">库存</th>
							<th class="col-sm-1">状态</th>
							<th class="col-sm-2 text-right">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $goodses $goodsid $goods}
						<tr>
							<td>{$goods['name']}</td>
							<td>{$goods['sn']}</td>
							<td><image src="{php echo tomedia($goods['image']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
							<td>{$goods['cost']}</td>
							<td>{$goods['price']}</td>
							<td>{$goods['quantity']}</td>
							<td>{php echo $this->getGoodsStatus($goods['status']);}</td>
							<td class="text-right">
								<a href="{php echo $this->createWebUrl('goods', array('op'=>'edit', 'id'=>$goodsid));}" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑"><i class="fa fa-pencil"></i></a>
								<a onclick="if(!confirm('删除后将不可恢复,确定删除吗?')) return false;" href="{php echo $this->createWebUrl('goods', array('op'=>'delete', 'id'=>$goodsid));}" class="btn btn-default btn-danger" data-toggle="tooltip" data-placement="top" title="" data-original-title="删除"><i class="fa fa-times"></i> </a>
							</td>
						</tr>
						{/loop}
						{if empty($goodses)}
						<tr>
							<td colspan="8">
								尚未添加商品
							</td>
						</tr>
						{/if}
					</tbody>
				</table>
				{$pager}
			</div>
		</div>
	</div>
</div>

{template 'common/footer'}